package com.xjrsoft.module.customerTwo.EMP.electricMeter.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.EMP.electricMeter.dto.TElectricMeterDto;
import com.xjrsoft.module.customerTwo.EMP.electricMeter.entity.TElectricMeter;
import com.xjrsoft.module.customerTwo.EMP.electricMeter.dto.TElectricMeterListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;

import java.math.BigDecimal;
import java.util.List;
import com.xjrsoft.module.customerTwo.EMP.electricMeter.mapper.TElectricMeterMapper;
import com.xjrsoft.module.customerTwo.EMP.electricMeter.service.ITElectricMeterService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import com.xjrsoft.module.customerTwo.EMP.t_water_cost_records_day.vo.GetWaterTotalVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author dongxinhang
 * @since 2023-07-18
 */
@Service
@AllArgsConstructor
public class TElectricMeterServiceImpl extends BaseService<TElectricMeterMapper, TElectricMeter> implements ITElectricMeterService {


	@Override
	public IPage<TElectricMeter> getPageList(TElectricMeterListDto pageListDto) {
		Wrapper<TElectricMeter> wrapper = Wrappers.<TElectricMeter>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getId()), TElectricMeter::getId, pageListDto.getId())
				.like(!StringUtil.isEmpty(pageListDto.getE_id()), TElectricMeter::getFid, pageListDto.getE_id())
				.like(!StringUtil.isEmpty(pageListDto.getDatetime()), TElectricMeter::getDatetime, pageListDto.getDatetime())
				.like(!StringUtil.isEmpty(pageListDto.getEng()), TElectricMeter::getEng, pageListDto.getEng());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public boolean addTElectricMeter(TElectricMeter tElectricMeter) {
		boolean isSuccess = this.save(tElectricMeter);
		return isSuccess;
	}

	@Override
	public boolean updateTElectricMeter(String id, TElectricMeter tElectricMeter) {
		tElectricMeter.setFid(Long.valueOf(id));
		return this.updateById(tElectricMeter);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

	@Override
	public boolean batchInsert(List<TElectricMeter> list) {
		return this.saveBatch(list);
	}

	@Override
	public BigDecimal getElectricCost(TElectricMeterDto dto) {
		return this.getBaseMapper().getElectricCost(dto);
	}

	@Override
	public GetWaterTotalVO getWaterTotal(TElectricMeterDto dto) {
		return this.getBaseMapper().getWaterTotal(dto);
	}

	@Override
	public int insertIgnore(List<TElectricMeter> list) {
		return this.getBaseMapper().insertIgnore(list);
	}

}